//案列，在函数中抛出Promise实例

function buy() {
    return new Promise(((resolve, reject) => {
        setTimeout(() => {
            if (Math.random() > 0.5) {
                resolve('买');
            } else {
                reject('不买')
            }
        }, Math.random() * 1000);
    }));
}
buy().then(data=>{
    console.log(data)
},err=>{
        console.log(err);
    }
);

console.log('hello word')